package cn.dada.dadarecipes.user.personal_account.controller;

import cn.dada.dadarecipes.base.response.JsonResult;
import cn.dada.dadarecipes.user.personal_account.pojo.dto.PersonalAccountBalanceParam;
import cn.dada.dadarecipes.user.personal_account.pojo.entity.PersonalAccount;
import cn.dada.dadarecipes.user.personal_account.pojo.vo.PersonalAccountVO;
import cn.dada.dadarecipes.user.personal_account.service.PersonalAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "01.04账户模块")
@Slf4j
@RestController
@RequestMapping("/v1/user")
public class PersonalAccountController {
    @Autowired
    PersonalAccountService personalAccountService;

    @ApiOperation(value = "账户余额与积分查询功能")
    @GetMapping("/queryBalance/{userId}")
    public JsonResult queryBalance(@PathVariable Long userId) {
        log.debug("用户查询:userId={}", userId);
        List<PersonalAccountVO> personalAccountVO = personalAccountService.queryBalance(userId);
        return JsonResult.ok(personalAccountVO);
    }

    @ApiOperation(value = "余额充值功能")
    @PostMapping("/balanceRecharge")
    public JsonResult balanceRecharge(PersonalAccountBalanceParam personalAccountBalanceParam) {
        log.debug("用户充值:personalAccount={}", personalAccountBalanceParam);
        personalAccountService.balanceRecharge(personalAccountBalanceParam);
        return JsonResult.ok();
    }
}
